function new_blog( id )
{
    var new_blog_div = "<form id = 'new_blog_form' action='savenewblogform' method='POST'>Title:<input type='text' id='new_blog_title' name='title' /><br>Catelog:<input type='text' name='catelog' /><br>Picture<input type='file' name='picture' /><br>Text:<textarea id='new_blog_text' name='text' cols='100' rows='10'></textarea><br><input type='button' value='save new' onclick='save_new_blog_req()'><input type='button' value='cancel' onclick='cancel_new_blog( )'></form>"
    var div = document.getElementById(id);
    div.innerHTML = new_blog_div;
}

function cancel_new_blog( )
{
    var div = document.getElementById('new_blog');
    div.innerHTML = "";
}

function update_blog( id )
{
    key = "";
    user = "";
    title = "";
    catelog = "";
    text = "";
    picture = "";
    time = "";
    var div = document.getElementById(id);
    var divs = div.getElementsByTagName("DIV");
    for ( var i = 0; i < divs.length; i++)
    {
	if (i == 0)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1 + 1;
	    key = temp.substr(index);
	}
	if (i == 1)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1;
	    user = temp.substr(index);
	}
	if (i == 2)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1;
	    title = temp.substr(index);
	}
	if (i == 3)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1;
	    catelog = temp.substr(index);
	}
	if (i == 4)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1;
	    text = temp.substr(index);
	}
	if (i == 5)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1;
	    picture = temp.substr(index);
	}
	if (i == 6)
	{
	    temp = new String(divs[i].innerHTML);
	    index = temp.indexOf(":") + 1;
	    time = temp.substr(index);
	}
    }

    var new_blog_div = "<form id = 'new_blog_form' action='savenewblogform' method='POST'>Title:<input type='text' id='new_blog_title' name='title' value="
	    + title
	    + " /><br>Catelog:<input type='text' name='catelog' value="
	    + catelog
	    + " /><br>Picture<input type='file' name='picture' value="
	    + picture
	    + " /><br>Text:<textarea id='new_blog_text' name='text' cols='100' rows='10'>"
	    + text
	    + "</textarea><br><input type='button' value='save new' onclick='save_new_blog_req()'><input type='button' value='cancel' onclick=\"cancel_update_blog('"
	    + id + "')\"></form>";
    div.innerHTML = new_blog_div;
}

function cancel_update_blog( id )
{
    window.location.reload();
}

function cantact_submit( )
{
    if ("" == document.getElementById("guest_email").value)
    {
	if (confirm("Dear guest, are you sure that you don't need to write your E-mail for receive message from me?"))
	{
	    var div = document.getElementById("contact_form");
	    div.submit();
	}
    }
    else
    {
	var div = document.getElementById("contact_form");
	div.submit();
    }
}

function cantact_reset( )
{
    if (confirm("Dear guest, are you sure that you want to reset all your infomations?"))
    {
	document.getElementById("guest_name").value = "";
	document.getElementById("guest_email").value = "";
	document.getElementById("guest_microblog").value = "";
	document.getElementById("contact_comments").value = "";
    }
}

function get_url_arguments( )
{
    var url = window.location.search;
    alert(url);
}

function show_comment_div( id )
{
    /*
     * if (document.getElementById) { target =
     * document.getElementById(targetid); if (target.style.display == "block") {
     * target.style.display = "none"; var aaa = document.all("aa"); var s = '';
     * for ( var i = 0; i < aaa.length; i++) { if (aaa[i].checked == true) { s +=
     * aaa[i].value; } } } else { target.style.display = "block"; } }
     */

    var div = document.getElementById(id);
    if (div.innerHTML == "")
    {
	div.innerHTML = "<div class='comment-title' style='dispay: none'>Post a comment</div><div style='padding: 10px;'>	<div id='respond' class='comment-body' style='border: solid 2px #DFDFDF;'><div class='comment-author-avatar'	style='display: inline; float: left; margin: 10px 10px 10px 10px;'>	<a href='/static/image/portrait.jpg' onclick='alert('//TODO this is for change portrait');' title='Change Your Avatar'><img src='/static/image/portrait.jpg' class='avatar avatar-64 photo avatar-default' height='64' width='64'	></img></a></div><div  style='width:600px;float:right;'><form action='postcomment?blogid="
		+ id
		+ "' method='post'	id='comment-form' style='border: 0 none;'>	<fieldset style='border: 0 none;'><div class='comment-form-row' style='margin: 10px;'>	<label for='email'>Name</label>	<input type='text' name='name' id='name' value='' size='30'style='width: 80%; border-radius: 3px; float: right; background-color: transparent; border: solid 1px #aaa;'	></input></div><div class='comment-form-row' style='margin: 10px;'>	<label for='email'>Email</label>	<input type='text' name='email' id='email' value='' size='30'style='width: 80%; border-radius: 3px; float: right; background-color: transparent; border: solid 1px #aaa;'	></input></div><div class='comment-form-row' style='margin: 10px;'>	<label for='email'>Website</label>	<input type='text' name='website' id='website' value='' size='30'style='width: 80%; border-radius: 3px; float: right; background-color: transparent; border: solid 1px #aaa;'	></input></div><div class='textarea-border' style='margin: 0 12px 0 0'>	<textarea name='comment' id='comment' cols='50' rows='3' tabindex='4' class='vital'style='height: 45px; width: 100%; padding: 4px 4px 4px 4px; border-radius: 3px; float: left; margin: 5px 0 10px 0; background-color: transparent;'	></textarea></div><div class='comment-buttons' style='margin: 0 10px 0 0'>	<input name='submit' type='submit' tabindex='5' value='Post your comment'class='submit' style='border-radius: 3px; float: right;'	></input></div><p style='clear: both;' class='subscribe-to-comments'>	<input type='checkbox' name='subscribe' id='subscribe' value='subscribe'style='width: auto;'	></input>	<label for='subscribe'>Notify me of followup comments via e-mail</label></p><!-- Threaded commenting powered by http://spectacu.la/ code. -->	</fieldset></form></div>	</div></div>";

    }
    else
    {
	div.innerHTML = "";
    }
}